package com.ruoyi.wechat.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.wechat.domain.WxCampsite;
import com.ruoyi.wechat.service.IWxCampsiteService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 营地营位Controller
 * 
 * @author ruoyi
 * @date 2024-10-28
 */
@RestController
@RequestMapping("/wechart/campsite")
public class WxCampsiteController extends BaseController
{
    @Autowired
    private IWxCampsiteService wxCampsiteService;

    /**
     * 查询营地营位列表
     */
    @PreAuthorize("@ss.hasPermi('wechart:campsite:list')")
    @GetMapping("/list")
    public TableDataInfo list(WxCampsite wxCampsite)
    {
        startPage();
        List<WxCampsite> list = wxCampsiteService.selectWxCampsiteList(wxCampsite);
        return getDataTable(list);
    }

    /**
     * 导出营地营位列表
     */
    @PreAuthorize("@ss.hasPermi('wechart:campsite:export')")
    @Log(title = "营地营位", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, WxCampsite wxCampsite)
    {
        List<WxCampsite> list = wxCampsiteService.selectWxCampsiteList(wxCampsite);
        ExcelUtil<WxCampsite> util = new ExcelUtil<WxCampsite>(WxCampsite.class);
        util.exportExcel(response, list, "营地营位数据");
    }

    /**
     * 获取营地营位详细信息
     */
    @PreAuthorize("@ss.hasPermi('wechart:campsite:query')")
    @GetMapping(value = "/{campsiteId}")
    public AjaxResult getInfo(@PathVariable("campsiteId") String campsiteId)
    {
        return success(wxCampsiteService.selectWxCampsiteByCampsiteId(campsiteId));
    }

    /**
     * 新增营地营位
     */
    @PreAuthorize("@ss.hasPermi('wechart:campsite:add')")
    @Log(title = "营地营位", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody WxCampsite wxCampsite)
    {
        return toAjax(wxCampsiteService.insertWxCampsite(wxCampsite));
    }

    /**
     * 修改营地营位
     */
    @PreAuthorize("@ss.hasPermi('wechart:campsite:edit')")
    @Log(title = "营地营位", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody WxCampsite wxCampsite)
    {
        return toAjax(wxCampsiteService.updateWxCampsite(wxCampsite));
    }

    /**
     * 删除营地营位
     */
    @PreAuthorize("@ss.hasPermi('wechart:campsite:remove')")
    @Log(title = "营地营位", businessType = BusinessType.DELETE)
	@DeleteMapping("/{campsiteIds}")
    public AjaxResult remove(@PathVariable String[] campsiteIds)
    {
        return toAjax(wxCampsiteService.deleteWxCampsiteByCampsiteIds(campsiteIds));
    }
}
